package com.itheima.exerciseTest.method20_29.method20;

import java.io.*;

public class Test extends Object {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
        Student s = new Student();
        s.setName("张三");
        s.setAge(23);

        // 创建对象序列化流
        ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(new File("backBurner\\j.txt")));
        oos.writeObject(s);
        oos.close();

        // 创建对象反序列化流
        ObjectInputStream ois = new ObjectInputStream(new FileInputStream("backBurner\\j.txt"));
        Object o = ois.readObject();
        System.out.println(o.toString());
    }
}
